<template>
	<view class="content">
		<!-- <view class="orderMessageWrapper" v-if="orderMsg!=''">
			<swiper class="order-wraper" :autoplay="true" :interval="6000" :duration="0" :vertical="true">
				<swiper-item class="order-box active" v-for="(item,index) in orderMsg" :key="index">
					<view class="imgBox">
						<image class="orderMessageImg" :src="item.head_url"  style="border-radius: 50%;" v-if="item.head_url"> </image>
						<image class="orderMessageImg" src="../../static/user.png" style="border-radius: 50%;" v-else> </image>
					</view>
					<view class="orderMessageWord">{{item.message}}</view>						
				</swiper-item>
				
			</swiper>				
		</view> -->
		<view class="nullshopping"  v-if="displayShow">
			<image src="../../static/nullshoppingCar.png" mode=""></image>
		</view>
		<view style="color: #BBBBBB; font-size:30upx; text-align: center; width: 100%; margin-top: 40upx;" v-if="displayShow">
			购物车竟然是空的
		</view>
		<view class="normal_content" v-if="!displayShow">  <!-- v-show="displayShow" -->
			<!-- 购物车头部信息 -->
			<view class="title">
				<!--<text class="theme">购物车(5)</text>-->
				<view class="operate">
					<!-- <text class="edit">编辑</text> -->
					 <text class="del"  @click="del">删除</text>
					<!-- <uni-icon class="msg" type="chatboxes" size="30"></uni-icon> -->
				</view>
			</view>
			<!-- 配送地址选择 -->
			<view class="address">
				<view><image src="http://rs.eonfox.cc/clzy/static/place-ico.png" mode="" style="width:48upx; height:48upx; float:right; margin-top:-8upx; margin-left: 15upx;"></image></view>
				<text class="addressDes font">送至：</text>
				<text class="addressDes">{{userAddress}} ></text>
			</view>
			
			<!-- 购物车商品信息 -->
			<scroll-view scroll-y="true" class="scroll-y">
				<view class="shoppingCarBox" v-for="(item,index) in shopCar" :key="index">
					<!-- 店铺抬头 -->
					<!-- <view class="storeTitle" @click="all_item(index)">
						<text class="empty" v-if="!is_alls[index]"></text>
						<image v-if="is_alls[index]" class="select empty" src="http://rs.eonfox.cc/clzy/static/choose.png" mode=""></image>
						<text class="store-Kind">{{item.shop_name}}</text>
					</view> -->
					<!-- 商品详情 -->
					<!-- 商品1 -->
					<view class="goodsItem " v-for='(items,indexs) in shopCar[0].goods'  :key='indexs' >
						<checkbox-group @click="checkbox_(indexs,items.sku_id,items.cart_id)">
							<!-- <checkbox :value="items.sku_id" :checked="check" v-if="items.state=='OK'"></checkbox> -->
							<checkbox  :value="items.sku_id" :checked="check"></checkbox>
						</checkbox-group>
						
						<view class="img-box">
							<image :src="qiniu+items.logo" mode=""></image>
						</view>
						<view class="infor-des">
							<view class="top">
								<view class="goods-detail-info">
									<!-- <text class="special normal">特价</text> -->
									<view class="goods-name normal">{{items.name}}</view>
									<view class="goods-content" style="color: #ccc;margin-left: 6px;">{{items.spu_string}}</view>
									<!-- <view class="goods-content" style="color: red;margin-left: 6px;" v-if="!items.json.display">该商品已过期</view> -->
								</view>
								<view class="goods-detail-money">
									<text class="price" style="text-align: center;" v-if='items.property==1'>{{items.price/100}}积分</text>
									<text class="price" style="text-align: center;" v-else="">￥{{items.price/100}}元</text>
									<!-- <text class="reduce-price">已降16</text> -->
								</view>
							</view>
							<view class="bottom">
								<view class="count">
									<text>x {{items.number}}</text>
								</view>
								<view class="count sta" style="color: red;" v-if="items.state=='SKUNOTEXIST'">
									<text>此商品规格不存在</text>
								</view>
								<view class="count sta" style="color: red;" v-if="items.state=='GOODSNOTEXIST'">
									<text>此商品不存在</text>
								</view>
								<view class="count sta" style="color: red;" v-if="items.state=='GOODSUNSHELVE'">
									<text>商品已下架</text>
								</view>
								<!-- <view class="tax">
									<text>税费：</text>
									<text>￥24.00</text>
									<uni-icon class="arrowdown" type="arrowdown" size="26"></uni-icon>
								</view> -->
							</view>
						</view>
					</view>
				</view>				
			</scroll-view>
			
			
			<!-- 底部商品总计 -->
			<!-- <view class="total">
				<view class="discount">
					<text>优惠活动：</text>
					<text>-￥0.00</text>
				</view>
				<view class="total-price">
					<text>本仓总计(不含税)：</text>
					<text>￥{{money}}</text>
				</view>
			</view> -->
			
		</view>
		<!-- 购物车遮罩页面 isShow  -> false -->
		<view class="mask_content" v-if="false">
			<view class="mask-box" >
				<view class="mask-item">
					<view class="address"  @click="newAddress">
						<text class="address-item">收货地址</text>
						<text class="add">{{userAddress}}</text>
						<uni-icon class="icon" type="arrowdown" size="24" @click="isShow=!isShow"></uni-icon>
					</view>
					<view class="deliver">
						<text class="address-item">配送</text>
						
							<picker class="pickerStyle" :range="expressType" :value="index" @change="pickerType">
							<view class="pickerSelect">{{expressType[index]}}</view>
						  </picker>
						
						
						<uni-icon class="icon" type="arrowdown" size="24"></uni-icon>
					</view>
					<view class="money">
						<text class="address-item">应付积分</text>
						<text class="add">
						<text >积分: {{submitList.total_credit/100}}</text>
						</text>
						<!-- <text class="tax">(含税费￥0.00)</text> -->
						<uni-icon class="icon" type="arrowdown" size="24"></uni-icon>
					</view>
					<view class="money">
						<text class="address-item">应付金额</text>
						<text class="add">
						<text style="margin-left: 20upx;">人民币: ¥{{submitList.total_money/100}}</text>
						</text>
						<!-- <text class="tax">(含税费￥0.00)</text> -->
						<uni-icon class="icon" type="arrowdown" size="24"></uni-icon>
					</view>
					<view class="agree">
						<image class="icon" src="http://rs.eonfox.cc/clzy/static/choose.png" mode=""></image>
						<text class="address-item">本人同意并接受以下协议</text>
						<text class="price-num">积分: {{total_credit/100}}</text>
						<text class="price-num">人民币: ¥{{total_money/100}}</text>
					</view>
				</view>
				<view class="submit-btn" @click="submitOrder">
					<text>提交订单</text>
				</view>
			</view>
		</view>	
			<!-- 新建地址页面-->
		<view class="mask_content"  v-if="isNew">	
			<view class="new-address-box">
				<view class="new-address-item_">
					<view class="address_">
						<text class="address-item">新建地址</text>
						<uni-icon class="icon" type="arrowdown" size="24" @click="isNew=!isNew"></uni-icon>
					</view>
					<view class="main-content">
						<view class="name-box">
							<input class="name" type="text" v-model="user.consignee" placeholder="收货人姓名(请使用真实姓名)"/>
						</view>
						<view class="phone-box">
							<input class="phone" type="text" v-model="user.phone" placeholder="手机号码"/>
						</view>
						<view class="area-box">
							<input disabled="true" class="area" type="text" :value="userAddress" placeholder="所在地区" @click="showMulLinkageThreePicker" />
						</view>
						<view class="details-box">
							<input class="details" type="text" v-model="user.details" placeholder="街道/小区门派等详细地址"/>
						</view>
						<view class="selected-box">
							<view class="empty-box">
								<radio id="main" checked="true"></radio>
							</view>
							<label class="selected-address" for="main" >设为默认地址</label>
						</view>
					</view>
				</view>
				<view class="submit-btn" @click="addAddress()">
					<text>添加地址</text>
				</view>
			</view>
		</view>
		<!-- 支付方式页面 -->
		<view class="mask_content" v-if="isPay">
			<view class="pay-methods" >
				<view class="methods-box">
					<view class="title-box">
						<text class="title">请选择支付方式</text>
						<image src="http://rs.eonfox.cc/clzy/static/closeBtn.png" mode="" @click="isPay=!isPay"></image>
					</view>
					<view class="pay-time-box">
						<!-- <text class="text">请在0小时30分钟内完成支付 金额</text> -->
						<text class="price">￥{{re_money}}元</text>
						<!-- <text class="symbol"></text> -->
					</view>
					<view class="ali-pay" :class="{active:(payMounted==1)}" @click="payMounted=1">
						<image src="http://rs.eonfox.cc/clzy/static/unknown.png" mode=""></image>
						<text class="ali">预付款</text>
						<image v-if="payMounted==1" class="select" src="http://rs.eonfox.cc/clzy/static/choose.png" mode=""></image>
					</view>
				     <!-- #ifdef APP-PLUS -->
					<view class="ali-pay" :class="{active:(payMounted==2)}" @click="payMounted=2">
						<image src="http://rs.eonfox.cc/clzy/static/ali_pay.png" mode=""></image>
						<text class="ali">支付宝</text>
						<image v-if="payMounted==2" class="select" src="http://rs.eonfox.cc/clzy/static/choose.png" mode=""></image>
					</view>
				    <!-- #endif -->
					<view class="weChat-pay"  :class=" {active:(payMounted==3)}" @click="payMounted=3">
						<image src="http://rs.eonfox.cc/clzy/static/wechat.png" mode=""></image>
						<text>微信支付</text>
						<image v-if="payMounted==3" class="select" src="http://rs.eonfox.cc/clzy/static/choose.png" mode=""></image>
					</view>
				</view>
				<view class="submit-btn" @click="submitForm()">
					<text>确认支付</text>
				</view>
			</view>
		</view>
		<!-- 底部结算 -->
		<view class="chooseAll" :style="{bottom:modeliphonex}" v-if="!displayShow">
			<view class="all" @click="all">
				<radio :checked="check" />
				<text>全选</text>
			</view>
			<view class="tax">
				<view class="price">
					<!-- <text>积分:</text>
					<text class="price-num">{{total_credit/100}}</text> -->
					<text> 人民币</text>
					<text class="price-num">¥{{total_money/100}}</text>
				</view>
				<!-- <text class="tax-price">商品税费 ￥55.36</text> -->
			</view>
			<view class="settlement" @click="enterSbumitPage">
				<text>结算</text>
			</view>
		</view>
		<view>
			<mpvue-picker  ref="mpvuePicker"   
			 @onConfirm="onConfirm" @onCancel="onCancel" ></mpvue-picker>
			<mpvue-city-picker  ref="mpvueCityPicker" 
			 @onCancel="onCancel" @onConfirm="onConfirm"></mpvue-city-picker>
		</view>
	</view>
</template>

<script>
	
	import uniPassword from '@/components/ku3gitxdx-payment-password/ku3gitxdx-payment-password.vue'
	import city from '../../common/city.data.js';
	import uniIcon from "@/components/uni-icon/uni-icon.vue";
	import uniPopup from "@/components/uni-popup/uni-popup.vue";
	import eonfox from '@/components/eonfox/eonfox.js';
	import pay from '@/components/eonfox/pay.js';
	import fns from '@/components/eonfox/fns.js';
	 import mpvuePicker from '@/components/mpvue-picker/mpvuePicker.vue';
    // https://github.com/zhetengbiji/mpvue-citypicker
    import mpvueCityPicker from '@/components/mpvue-citypicker/mpvueCityPicker.vue'
    import cityData from '@/common/city.data.js';

	var ef = new eonfox();
	// var pay = new pay();
	
	export default {
		data() {
			return {
				user:{
					consignee:'',// [str] [必填] [收货人]
					phone:'',
					province:'',//[str] [必填] [省]
					city:'',//        [str] [必填] [市]
					district:'',//    [str] [必填] [区]
					details:"",//     [str] [必填] [详址]
					default:1,//     [int] [可选] [默认地址。1是0否]
				},
				orderMsg:[],
				edit:false,
				address_id:'',
				shopCar:[],
				re_ids:[],
				re_money:'0.00',
				re_sum:0,
				pickerText: '',
				money:'0.00',
				payMounted:1,//1预付款2支付宝3微信
				checkeds:[],
				userAddress:'请添加收货地址',
				qiniu:'',
				isShow: false,
				isBackgroundShow: false,
				isAli: false,
				isWeCaht: true,
				isNew: false,
				isPay: false,
				isAll:false,
				is_alls:[],
				user_addressList:[],
				pay_pass_display:false,
				order_id:'',
				order_method:'money',
				OOrder:[],
				pay_method:'',
				displayShow:false,
				paymentPasswordDispaly:true,
				payMoneyDispaly:false,
				cart_id:'' ,//购物车id
				checked_values:[], //选中的商品的规格ID
				cart_values:[], //选中商品的购物车ID
				total_credit:'',//所需积分
				total_money:'',//所需钱
				submitList:[], //提交列表
				check:false,
				expressType:[] ,//快递类型
				expressId:[] ,//快递id
				index:0,
				modeliphonex:'',
				checktype:false
			}
		},
		onShow() {
			var _this=this
			       _this.pay_pass_display=false;
			       _this.isShow=false;
			       _this.isNew=false;
			       _this.isPay=false;
				   _this.shopCar=[]
				   _this.load()
				},
		onLoad() {
			var _this=this
			       _this.pay_pass_display=false;
			       _this.isShow=false;
			       _this.isNew=false;
			       _this.isPay=false;
				   _this.shopCar=[]
				   _this.load()
		},
		components: {
			uniIcon,
			eonfox,
			mpvuePicker,
            mpvueCityPicker,
			uniPassword
		},
		methods: {
			// 判断用户登录
			uChecked(){
				var ac = null;
				ef.submit({
					request: {
						u: ['USERSELF']
					},
					callback: function(data) {
						let loginC = data.data.u.errno
						if(loginC==1){
							uni.showToast({
								title:'请先登录',
								icon:'none',
								success(){
									if (ac) {
										clearInterval(setIntervalID);
									}
									var ac = setTimeout(function(){
										
										uni.reLaunch({
											url:'../../pages/register/register'
										});
										return
										
										// uni.reLaunch({
										// 			url:'../../pagesA/threelogin/threelogin'
										// 		})
									},1000)
								}
							})
						}
					}
					
				})
			},
			checkbox_(index,ggid,cartID){
				var _this=this;
				_this.checktype=!_this.checktype
				if(_this.checked_values.indexOf(ggid)==-1){
					_this.checked_values.push(ggid)
				}else{
					_this.isAll=false;
					for(var i in _this.checked_values){
						if(_this.checked_values[i]==ggid){
							_this.checked_values.splice(i,1)
						}
					}
				}
				
				if(_this.cart_values.indexOf(cartID)==-1){
					_this.cart_values.push(cartID)
				}else{
					_this.isAll=false;
					for(var i in _this.cart_values){
						if(_this.cart_values[i]==cartID){
							_this.cart_values.splice(i,1)
						}
					}
				}
				console.log('规格id',_this.checked_values)
				console.log('购物车id',_this.cart_values)
				this.getShoppingcart()
			},
			getShoppingcart(){
				var that=this;
				ef.submit({
					request:{
						cost:['SHOPCARTSELFDATA',[{goods_sku_id:that.checked_values}]]
					},
					callback(data){
						var datalist=fns.checkError(data,'cost',function(errno,error){
							uni.showToast({
								title:error,
								icon:'none'
							})
						})
						console.log('datalist:------------------->',datalist)
						if(datalist.cost && datalist.cost.statistic){
							that.total_credit= datalist.cost.statistic.checked_total_credit
							that.total_money= datalist.cost.statistic.checked_total_money
						}
					},
					error(err){
						fns.err('err',err,1)
					}
				})
			},
			
			paymentPasswordBack(e){
				console.log("支付密码点击了返回，进来了",e);
				this.pay_pass_display=false;
			},
			onConfirms(e) {
				var _this = this;
				let password = e.value;
				console.log('password', password, password.length);
				if( password.length != 6 ){
					fns.err('请正确输入密码');
				}else{
					
					if( _this.payMoneyDispaly ){
						return false;
					}
					
					_this.payMoneyDispaly = true; 
					
					pay.shoppingCar(_this.order_id,'user_money',password,function(){
						fns.success('支付成功',function(){
							uni.showToast({
								title:'支付成功',
								success() {
									_this.pay_pass_display = false;
									setTimeout(function(){
										_this.payMoneyDispaly = false;
										uni.navigateTo({
											url:'../../pagesB/my-order/my-order'
										})
									},1000)
								}
							})
						});
					})
				}
				// this.pay_pass_display=false
			},
			
			del(){
				var that=this 
				if(!that.cart_values[0]){
					uni.showToast({
						title:'未选中商品',
						icon:'none'
					})
					return
				}else{
					

					
					
					ef.submit({
						request:{
							del:['SHOPCARTSELFREMOVE',[{cart_ids:that.cart_values}]]
						},
						callback(data){
							console.log('删除商品',data.data);
							if(fns.checkError(data,'del',function(errno,error){
								fns.err(error)
							})){
								fns.success('清理成功',function(){
									that.edit=false;
									that.shopCar = [];
									that.load();
									// that.$nextTick(function(){
									// 	 that.load();
									// })
								})
							}
						},
						error(err){
							fns.err('err',err,1)
						}
					})
				}
				
			},
			remove(ids){
				var _this=this,shopCar=_this.shopCar
				for(var i in shopCar){
					if(ids.indexOf(shopCar[i].id)!=-1){
						shopCar.splice(i,1)
					}
				}
				_this.re_ids=[];
				_this.re_order()
			},
			all_item(index){
				var _this=this,re_ids=this.re_ids[index];
				this.re_ids[index]=[]
				if(this.is_alls[index]){
					this.isAll=false;
				}else{
					for (let s of _this.shopCar[index].shop_goods) {
							this.re_ids[index].push(s.cart_id)
						}
				}
				this.is_alls[index]=!this.is_alls[index]
				
				console.log('is_alls',this.is_alls)
				
				_this.re_order()
			},
			all(){
				this.check=!this.check
				var _this=this
				_this.checked_values=[]
				_this.cart_values=[]
				var item=_this.shopCar[0].goods
				if(_this.check==true){
					for(var i = 0, lenI =item.length; i < lenI; ++i){
						// items.sku_id,items.cart_id
						console.log('item',item)
						_this.checked_values.push(item[i].sku_id)
						_this.cart_values.push(item[i].cart_id)
					}
					_this.isAli=true
				}else{
					_this.isAli=false
					_this.checked_values=[]
					_this.cart_values=[]
				}
				console.log('规格id',_this.checked_values)
				console.log('购物车id',_this.cart_values)
				_this.getShoppingcart()
			},
			addAddress(){
				var info=this.user,_this=this;
				if(!info.consignee||!info.phone||!info.province||!info.city||!info.district||!info.details){
					uni.showToast({
						title:'有未填项',
						icon:'none'
					})
					return;
				}	
				ef.submit({
					request:{
						add:['USERADDRESSSELFADD',[info]]
					},
					callback(data){
						var address=fns.checkError(data,'add',function(errno,error){
							uni.showToast({
								title:error,
								icon:'none'
							})
						})
						if(address.add){
							fns.success('添加成功',function(){
								_this.isNew=false;
								_this.isShow=true;
								_this.address_id=address.add
							})
						}
					},
					error(err){
						fns.err('err',err,1)
					}
				})
			},
			// 进入提交页面
			enterSbumitPage() {
				if(this.checked_values==''){
					fns.err('未选中商品')
					return;
				}
				if(!this.userAddress){
					this.isNew = true;
				}else{
					this.isShow = true;
				}
				
				var that=this;
				ef.submit({
					request:{
						s:['SHOPORDERSELFCONFIRM',[{cart_id:that.cart_values,address_id:that.address_id}]]
					},
					callback(data){
						var datalist=fns.checkError(data,'s',function(errno,error){
							uni.showToast({
								title:error,
								icon:'none'
							})
						})
						console.log(datalist)
						if(datalist.s && datalist.s.statistic){
							that.submitList=datalist.s.statistic
						}
					},
					error(err){
						fns.err('err',err,1)
					}
				})
				
				//7-29 wan
				var expressId = that.expressId[that.index] 
				console.log('expressIdexpressId',expressId)
				uni.navigateTo({
					url:'../../pagesA/submitOrder/submitOrder?checked_values='+that.checked_values+'&cart_values='+that.cart_values+'&address_id='+that.address_id+'&expressId='+expressId
				})
			},
			
			AlipayMethod() {
				this.isAli = !this.isAli
				this.isWeCaht = !this.isWeCaht;
			},
			WePayMethod() {
				this.isAli = !this.isAli
				this.isWeCaht = !this.isWeCaht
			},
			//提交订单
			submitForm(){
				
				var _this=this,ids=this.re_ids,order=[],shopCar=this.shopCar,pay_method,address_id=this.address_id;
				uni.showLoading({
					title:'正在提交订单',
					success() {
						var temp_order = {};
						for (let i in ids) {
							temp_order.shop_id=shopCar[i].shop_id;
							temp_order.shop_goods=[];
							for (let s of shopCar[i].shop_goods) {
								var item={};
								item.goods_sku_id=s.goods_sku_id
								item.number=s.number
								temp_order.shop_goods.push(item)
							}
							order.push(temp_order);
							_this.OOrder=order;
						   console.log("order11",_this.OOrder);
						}
						console.log("order",order);
						// return
						
                         //选择支付
						var shopOrderSelfAddConfig = {
							address_id:_this.address_id,
							shop:_this.OOrder
						};
						
						switch (_this.payMounted){
							case 1:
							_this.pay_method='user_money';
							_this.pay_pass_display = true;
							shopOrderSelfAddConfig.pay_method = 'user_money';
							_this.shopOrderPayment(shopOrderSelfAddConfig, function(response){
								_this.pay_money(response);
							});
								break;
							case 2:
							_this.pay_pass_display=false;
							_this.pay_method='alipay'
							shopOrderSelfAddConfig.pay_method = 'alipay'; //支付方式 weixinpay 微信支付、alipay 支付宝支付
							shopOrderSelfAddConfig.alipay_trade_type = "APP";
							_this.shopOrderPayment(shopOrderSelfAddConfig, function(response){
								_this.pay_alipay(response);
							});
								break;
							case 3:
							_this.pay_pass_display=false;
							_this.pay_method = 'weixinpay';
							shopOrderSelfAddConfig.pay_method = 'weixinpay';
							// #ifdef MP-WEIXIN
							shopOrderSelfAddConfig.weixin_trade_type = "JSAPI";
							wx.login({
								//微信小程序登录获取code
								success(res) {
									console.log("wx.login"+JSON.stringify(res));
									if( res.code ){
										_this.code = res.code;
										shopOrderSelfAddConfig.weixin_login_code = res.code;
										_this.shopOrderPayment(shopOrderSelfAddConfig, function(response){
											_this.pay_weixin(response);
										});
									} else {
										_this.isDisable = false;
										console.log('登录失败！' + res.errMsg );
										console.log('登录失败！' + JSON.stringify(res) );
										uni.showToast({
											title: '登录失败！' + res.errMsg,
											icon: 'none',
											//duration: 30000
										});
									}
								}
							});
							// #endif
							// #ifdef APP-PLUS
							shopOrderSelfAddConfig.weixin_trade_type = "APP";
							_this.shopOrderPayment(shopOrderSelfAddConfig, function(response){
								_this.pay_weixin(response);
							});
							// #endif
								break;		
						}
						
						
					}
				})
			},
			//付款
			shopOrderPayment( shopOrderSelfAddConfig, callbackFunction ){
				var _this = this;
				//如果不是函数，则默认空函数
				if(typeof callbackFunction !='function'){
					callbackFunction = function(){};
				}
				
				ef.submit({
					request: {
						s: ['SHOPORDERSELFADD', [shopOrderSelfAddConfig]]
					},
					callback(data){
						 uni.hideLoading();
						console.log('调起支付',data)
						var shopOrderSelfAddData = fns.checkError(data,'s',function(errno,error){
							uni.showToast({
								title:error,
								icon:'none',
								duration: 3000
							});
						});
						if( !shopOrderSelfAddData ){
							
							return false;
						}
						_this.order_id = shopOrderSelfAddData.s.order_id;
						console.log('提交订单', shopOrderSelfAddData);
						return callbackFunction(shopOrderSelfAddData.s);
						
					},
					error(err){
						fns.err('提交订单失败', err, 1);
						
					}
				});
				
			},
			//微信支付  
			pay_weixin(wxArr){
				var _this = this;
				// #ifdef APP-PLUS
				var orderInfo = {
					appid:wxArr.appid,
					partnerid:wxArr.mch_id,//商户号
					prepayid:wxArr.prepay_id,//预支付交易会话ID
					package:'Sign=WXPay',//扩展字段,暂填写固定值Sign=WXPay
					noncestr:wxArr.nonce_str,//随机字符串
					timestamp:wxArr.time_stamp,//时间戳	
					sign:wxArr.pay_sign,//签名
				};
				// #endif
				uni.requestPayment({
					// #ifdef MP-WEIXIN
					provider: 'wxpay',
					timeStamp: String(wxArr.time_stamp),
					nonceStr: wxArr.nonce_str,
					package: 'prepay_id=' + wxArr.prepay_id,
					signType: wxArr.sign_type,
					paySign: wxArr.pay_sign,
					orderInfo:wxArr,
					// #endif
					// #ifdef APP-PLUS
					provider:'wxpay',
					orderInfo: JSON.stringify(orderInfo),
					// #endif
					success: function(res) {
						_this.test = '支付成功?'
						console.log('支付成功success:' , JSON.stringify(res));
						// return
						if (res.errMsg == 'requestPayment:ok') {
							_this.test='支付成功'
							uni.showToast({
								title: '支付成功',
								icon: 'none',
								success() {
									_this.payMoneyDispaly = false;
									
									uni.navigateTo({
										url:'../../pagesB/my-order/my-order'
									})
								}
							})	
						} 
					},
					fail: function(err) {
						
						_this.test = '调用支付失败' + JSON.stringify(err);
						console.log('调用支付失败' + JSON.stringify(err));
						return false;
					},
				});
				
			},
			
			//支付宝支付
			pay_alipay(response){
				var _this=this;
				_this.pay_pass_display=false;
				var ali = response.alipay;
				uni.requestPayment({
					provider: 'alipay',
					orderInfo:ali,
					success: function (res) {
						console.log('success:' + JSON.stringify(res));
						uni.showToast({
							title:'支付成功',
							icon:'none',
							success() {
								setTimeout(function(){
									_this.payMoneyDispaly = false;
									
									uni.navigateTo({
										url:'../../pagesB/my-order/my-order'
									});
								},1500)
							}
						});
					},
					fail: function (err) {
						console.log('fail:' + JSON.stringify(err));
					}
				});
			
			},
			
			//调起预付款支付
			pay_money( response ){
				var _this = this;
				console.log('pay_money()', response);
				uni.showToast({
					title:'请输入支付密码',
					icon: 'none',
					success() {
						_this.order_id = response.shop_order_id;
					}
				});
			},
			load(){
				this.uChecked();
				var _this = this;
				
				_this.cart_id='' //购物车id
				_this.checked_values=[] //选中的商品的规格ID
				_this.cart_values=[]//选中商品的购物车ID
				_this.total_credit=''//所需积分
				_this.total_money=''//所需钱
				_this.submitList=[] //提交列表
				_this.check=false
				_this.expressType=[] //快递类型
				_this.expressId=[] //快递id
				_this.index=0
				
				
				var ef = new eonfox();
				ef.submit({
					request: { 
						s:['USERSELF'],  //个人信息，判断是否登录
						carList:['SHOPCARTSELFDATA'],   //购物车列表 
						config: ['APPLICATIONCONFIG'], //配置信息
						address:['USERADDRESSSELFGET'], // 收货地址
						express:['APPLICATIONSHIPPINGSELFOPTIONS',[{module:'shop_order'}]] ,//快递信息
						orderMsg:['SHOPORDERGETNUMLIST'], //订单人
						},
					callback: function(data) {
						
						
						var data=fns.checkError(data,'s',function(errno,error){
							
						})
						console.log(data);
						
						if(data.carList && data.carList.shop && data.carList.shop[0].goods){
							_this.shopCar=data.carList.shop
							console.log('购物车信息',_this.shopCar)
						}
						if(data.carList.status==1){
							_this.displayShow=false
						}if(data.carList.status==0){
							_this.displayShow=true
						}
						console.log('displayShow',_this.displayShow)
						
						//快递类型
						if(data.express){
							var arr = data.express
						}
						
						arr.forEach(item=>{
							_this.expressType.push(item.name)
							_this.expressId.push(item.id)
						})
						if(data.config && data.config.qiniu_domain){
							_this.qiniu=data.config.qiniu_domain
						}
						if(data.address && data.address!=''){
								var address=data.address
									_this.userAddress=address.province+'-'+address.city+'-'+address.district;
									_this.user.province=address.province;
									_this.user.city=address.city;
									_this.user.district=address.district;
									_this.user.address=address.address;
									_this.user.consignee=address.consignee;
									_this.user.phone=address.phone;
									_this.address_id=address.id
									console.log('address',_this.userAddress);
						}
						if(data.orderMsg){
							_this.orderMsg = data.orderMsg
							console.log('orderMsg',_this.orderMsg)
						}
						
					},
					error: function(err) {
						fns.err('err',err,1)
					}
				});
			},
			pickerType(e){
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.index = e.target.value
			},
			colseBtn() {
				this.isBackgroundShow = !this.isBackgroundShow;
				this.isAli = !this.isAli
				this.isWeCaht = !this.isWeCaht
				this.isNew = !this.isNew;
				this.isPay = !this.isPay;
			},
			newAddress() {
				this.isShow = false;
				this.isNew = true
			},
			submitOrder(){
				// checked_values:[], 
				// cart_values:[],
				var expressId = this.expressId[this.index] 
				
				console.log('address_id',this.address_id)
				if(!this.address_id){
					uni.showToast({
						title:'请填写收货地址',
						icon:'none'
					})
					return
				}
				var _this=this
				uni.navigateTo({
					url:'../../pagesA/submitOrder/submitOrder?checked_values='+this.checked_values+'&cart_values='+this.cart_values+'&address_id='+this.address_id+'&expressId='+expressId
					
				})
				
				
			},
			payMethods() {
				this.isNew = !this.isNew;
				this.isPay = !this.isPay;
			},
			onCancel(e) {
                console.log(e)
            },
            // 单列
            showSinglePicker() {
                this.pickerValueArray = this.pickerSingleArray
                this.mode = 'selector'
                this.deepLength = 1
                this.pickerValueDefault = [0]
                this.$refs.mpvuePicker.show()
            },
            // 二级联动选择
            showMulLinkageTwoPicker() {
                this.pickerValueArray = this.mulLinkageTwoPicker
                this.mode = 'multiLinkageSelector'
                this.deepLength = 2
                this.pickerValueDefault = [0, 0]
                this.$refs.mpvuePicker.show()
            },
            // 三级联动选择
            showMulLinkageThreePicker() {
                this.$refs.mpvueCityPicker.show()
            },
            onConfirm(e) {
				console.log(e);
				var label=e.label;
                this.userAddress = label;
				var labelArr=label.split('-');
				this.user.province=labelArr[0];
				this.user.city=labelArr[1];
				this.user.district=labelArr[2];
            }
		},
		onBackPress() {
          if (this.$refs.mpvuePicker.showPicker) {
            this.$refs.mpvuePicker.pickerCancel();
            return true;
          }
          if (this.$refs.mpvueCityPicker.showPicker) {
            this.$refs.mpvueCityPicker.pickerCancel();
            return true;
          }
        },
        onUnload() {
            if (this.$refs.mpvuePicker.showPicker) {
                this.$refs.mpvuePicker.pickerCancel()
            }
            if (this.$refs.mpvueCityPicker.showPicker) {
                this.$refs.mpvueCityPicker.pickerCancel()
            }
        }
		
}
</script>
<style>
	.yuan{
		width: 45upx;
		height: 45upx;
		border: 1upx #4FA5E1 solid;
		border-radius: 50%;
	}
	.yuanImage{
		width: 45upx;
		height: 45upx;
		background-image: url('http://mp.emshop.eonfox.com/zrhzstatic/muying/gou.png');
	}
	.del{
		color: #FFFFFF;
	}
	.remove{
		opacity: 0.6;
	}
	
	.nullshopping{
		width: 120upx;
		height: 120upx;
		margin-top: 100upx;
		margin-left: 315upx;	
	}
	.nullshopping image{
		width: 100%;
		height: 100%;
	}
	.chooseAll{
		width :100%;
		height: 90upx;
		color :#333;
		background-color :#fff;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction :row;
		font-size :24upx;
		position :absolute;
		/* #ifdef APP-PLUS || H5 */
		bottom: 0px;
		/* #endif */
		/* #ifdef MP-WEIXIN */
		bottom: 0;
		/* #endif */
		left: 0;
	}
		
		.all{
			
				flex :1;
				height: 90upx;
				display :flex;
				justify-content: center;
				align-items :center;
				border-top :1px solid #ccc;
		}
			.empty{
				display: inline-block;
				width: 40upx;
				height :40upx;
				border: 1px solid #ccc;
				border-radius: 50%;
				margin: 0 25upx;
			}
				
		.tax{
			flex :2;
			height: 90upx;
			border-top :1px solid #ccc;
			display: flex;
			justify-content :center;
			text-align: right;
			flex-direction :column;
			padding-right :5px;
			line-height: 50upx;
		}
		
			.price-num{
				color: #E51C23;
				margin-right: 20upx;
			}
				
			
			.tax-price{
				font-size: 20upx;
				color: #ccc;
			}
		.settlement{
			flex :1;
			height: 90upx;
			display: flex;
			justify-content :center;
			align-items :center;
			background-color: #E51C23;
			color: #fff	;
		}
		/* /banner处  字 */
		.orderMessageWrapper{
			position: absolute;
			z-index: 99;
			top: 100upx;
			left: 30upx;
			width: 60%;
		    height: 60upx;		
		    color: #fff;
		    
		      
		}
		.order-wraper{
			height: 60upx;
			width: 100%;
			  
		}
		.order-box{
			height: 60upx;
			background: rgba(0,0,0,0.7);
			border-radius: 100upx;	
			display: flex;
			align-items: center;
		}
		.order-box.active{
			animation: star_rotate linear 6s infinite reverse 0s;
		}
		.imgBox{
		    width: 60upx;
		    height: 60upx;
		}
		.orderMessageImg{
		    width: 60upx;
		    height: 60upx;
		}
		.orderMessageWord{
			padding: 0 20upx;
		    font-size: 24upx;
		    flex: 1;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
		}
		@keyframes star_rotate{
		    0%{
				opacity: 0;
		        /* transform: rotateY(360deg) */
		    }
			25%{
				opacity: 0;
				/* transform: rotateY(180deg) */
			}
			50%{
				opacity: 0.5;
			}
			75%{
				opacity: 1;
			}
		    100%{
				opacity: 1;
		        /* transform: rotateY(180deg) */
		    }
		}
		.scroll-y{
			height: calc(100vh - 410upx) !important;
		}
		/* #ifdef MP-WEIXIN */
		.scroll-y{
			height: calc(100vh - 240upx) !important;
		}
		/* #endif */
</style>
<style scoped lang="stylus" ref="stylesheet/stylus">
	.content
		width 100%
		//height calc(100vh - 100upx) !important
		.normal_content
			// padding-bottom 60px
			//height calc(100vh - 100upx) !important
			width 100%
			position relative
			border 1px #ccc solide
			.title
				display flex
				justify-content center
				align-items center
				width 100%
				height 60upx
				font-size 34upx
				position relative
				border-bottom 1px #e4e0e0 solid
				.theme
					width 100%
					text-align center
				.operate
					width 120upx
					position absolute
					right 0upx
					font-size 28upx
					background-color #e51c23
					height 60upx
					line-height 60upx
					text-align center
					.edit
						margin-right 20upx
						float left
			.address
				display flex
				justify-content left
				align-items center
				width 100%
				height 70upx
				// background-color #ccc
				position relative
				border-bottom 1px solid #f4f3f3
				// margin-bottom 30upx
				.addressIcon
					// width 20upx
					height 20upx
					position absolute
					left 10upx
					top 8upx
				.addressDes
					font-size 24upx
				.font
					margin 0 10upx 0 
			.shoppingCarBox
				width 100%
				.storeTitle
					width 100%
					height 100upx
					display flex
					justify-content left
					align-items center
					border-bottom 1px solid #f4f3f3
					.empty
						width 40upx
						height 40upx
						border 1px solid #ccc
						border-radius 50%
						margin 0 25upx
					.store-Kind
						font-size 32upx
						color #666
				.goodsItem
					width 100%
					height 180upx
					display flex
					justify-content center   // 水平居中
					align-items center       // 垂直居中
					flex-direction row
					border-bottom 1px solid #f4f3f3
					.empty
						display inline-block
						width 40upx
						height 40upx
						border 1px solid #ccc
						border-radius 50%
						margin 0 25upx
					.img-box
						width 20%
						image
							width 120upx
							height 100upx
					.infor-des
						width 70%
						height 100%
						font-size 24upx
						color #333
						.top
							width 100%
							height 50%
							.goods-detail-info
								width 70%
								height 40%
								margin-top 10upx
								float left
							.goods-detail-money
								width 30%
								height 40%
								float right
								margin-top 10upx	
								.normal
									margin-right 20upx
								.special
									color red
								.price
									font-weight 600
								.reduce-price
									margin-left 90upx
									text-align right
									color red
						.bottom
							width 100%
							// height 50%
							.count
								width 95%
								text-align right
							.tax
								width 98%
								text-align right
								color #ccc
								margin-top -10upx
			.total
				width 96%
				height 150upx
				font-size 24upx
				color #333
				text-align right
				.discount
					padding 20upx 0
			.maskd
				width 100%
				.uni-popup
					width 100%
					.IntelligentSorting
						width 100%
						height 400px
				
		.mask_content
			width 100%
			height 600px
			background-color rgba(0, 0, 0 , 0.5)
			position fixed
			top 0
			left 0
			.mask-box
				position fixed
				/* #ifdef APP-PLUS || H5 */
				bottom 100upx
				/* #endif */
				/* #ifdef MP-WEIXIN */
				bottom 0
				/* #endif */
				left 0
				font-size 26upx
				width 100%
				height 460px
				background-color #fff
				.mask-item
					width 100%
					height 89%
					display flex
					justify-content center
					align-items center
					flex-direction column
					text-align center
					background-color #fff

					.address, .deliver, .ticket, .invoice, .luckbag, .money, .agree
						flex 1
					.deliver, .ticket, .invoice, .luckbag, .money, .agree
						border-top 1px solid #ccc
					.address
						width 100%
						background-color #fff
						display flex
						justify-content center
						align-items center
						flex-direction row
						.address-item
							flex 3
							text-align left
							padding 10px
						.add
							flex 2
							color #E60B30
						.icon
							flex 1
							color #E60B30
							
					.deliver
						width 100%
						display flex
						justify-content center
						align-items center
						flex-direction row
						.address-item
							flex 3
							text-align left
							padding 10px
						.add
							flex 2
						.icon
							flex 1
					.ticket
						width 100%
						display flex
						justify-content center
						align-items center
						flex-direction row
						.address-item
							flex 3
							text-align left
							padding 10px
						.add
							flex 2
						.icon
							flex 1
					.invoice
						width 100%
						display flex
						justify-content center
						align-items center
						flex-direction row
						.address-item
							flex 3
							text-align left
							padding 10px
						.add
							flex 2
						.icon
							flex 1
					.luckbag
						width 100%
						display flex
						justify-content center
						align-items center
						flex-direction row
						.address-item
							flex 3
							text-align left
							padding 10px
						.add
							flex 2
						.icon
							flex 1
					.money
						width 100%
						display flex
						justify-content center
						align-items center
						flex-direction row
						.address-item
							flex 3
							text-align left
							padding 10px
						.add
							flex 2
							color #E60B30
						.tax
							color #ccc
							font-size 20upx
						.icon
							flex 1
					.agree
						width 100%
						display flex
						justify-content center
						align-items center	
						flex-direction row
						.address-item
							flex 3
							text-align left
							padding 10px
						.add
							flex 2
						.icon
							margin-left 5px
							width 24px
							height 24px
				.submit-btn
					width 100%
					height 60px
					background-color #E60B30
					text-align center
					padding-top 15px
					color #fff
			.new-address-box
				position fixed
				/* #ifdef APP-PLUS || H5 */
				bottom 100upx
				/* #endif */
				/* #ifdef MP-WEIXIN */
				bottom 0
				/* #endif */
				left 0
				font-size 26upx
				width 100%
				height 325px
				background-color #ccc
				.new-address-item_
					width 100%
					height 275px
					background-color #fff
					.address_
						width 95%
						height 50px
						margin 0 auto
						display flex
						justify-content center
						align-items center
						flex-direction row
						.address-item
							flex 1
							text-align left
						.icon
							flex 1
							text-align right
					.main-content
						width 100%
						height 220px
						display flex
						justify-content center
						align-items center
						flex-direction column
						text-align center
						border-top 1px solid #ccc
						.name-box
							flex 1
							width 100%
							height 100%
							display flex
							text-align left
							align-items center
							background-color #fff
							.name
								width 90%
								height 70%
								padding-left 10px
								background-color #f4f3f3
								margin 0 auto
							
						.phone-box
							flex 1
							width 100%
							height 100%
							display flex
							text-align left
							align-items center
							.phone
								width 90%
								height 70%
								padding-left 10px
								background-color #f4f3f3
								margin 0 auto
						.area-box
							flex 1
							width 100%
							height 100%
							display flex
							text-align left
							align-items center
							background-color #fff
							.area
								width 90%
								height 70%
								padding-left 10px
								background-color #f4f3f3
								margin 0 auto
						.details-box
							flex 1
							width 100%
							height 100%
							display flex
							text-align left
							align-items center
							.details
								width 90%
								height 70%
								padding-left 10px
								background-color #f4f3f3
								margin 0 auto
						.selected-box
							flex 1
							width 90%
							height 100%
							margin 0 auto
							display flex
							align-items center
							text-align left
							background-color #fff
							.empty-box
								flex 1
								height 69%
								display flex
								align-items center
								.empty
									width 20px
									height 20px
									border-radius 50%
									border 1px solid #333
							.selected-address
								flex 9
								height 70%
								display flex
								align-items center
				.submit-btn
					width 100%
					height 50px
					background-color #E60B30
					text-align center
					padding-top 15px
					color #fff
			.pay-methods
				position fixed
				bottom 0
				left 0
				font-size 26upx
				width 100%
				height 300px
				background-color pink
				.methods-box
					width 100%
					height 250px
					background-color #fff
					display flex
					justify-content center
					align-items center
					flex-direction column
					text-align center
					.title-box
						width 100%
						flex 0.9
						display flex
						align-items center
						justify-content center
						border-bottom 1px solid #ccc
						position relative
						.title
							width 100%
						image
							position absolute
							top 18px
							right 10px
							width 25px
							height 25px
					.pay-time-box
						width 100%
						flex 1
						display flex
						align-items center
						justify-content center
						border-bottom 1px solid #ccc
						.text
							flex 5.5
							text-align right
						.price
							flex 1.5
							color #E60B30
							text-align left
						.symbol
							flex 2
					.ali-pay
						width 100%
						flex 0.8
						display flex
						align-items center
						justify-content left
						padding-left 20px
						border-bottom 1px solid #ccc
						position relative
						image
							width 24px
							height 24px
						.select
							position absolute
							top 10px
							right 18px
					.weChat-pay
						width 100%
						flex 0.8
						display flex
						align-items center
						justify-content left
						padding-left 20px
						position relative
						image
							width 24px
							height 24px
						.select
							position absolute
							top 10px
							right 18px
					.active
						background-color #ccc
				.submit-btn
					width 100%
					height 50px
					background-color #E60B30
					text-align center
					padding-top 15px
					color #fff
					
</style>
